<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Add a new directory</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.ziparchive.html">ZipArchive</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ziparchive.addfile.html">ZipArchive::addFile</a></div>
 <div class="up"><a href="class.ziparchive.html">ZipArchive</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="ziparchive.addemptydir" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ZipArchive::addEmptyDir</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PECL zip &gt;= 1.8.0)</p><p class="refpurpose"><span class="refname">ZipArchive::addEmptyDir</span> &mdash; <span class="dc-title">Add a new directory</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-ziparchive.addemptydir-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>ZipArchive::addEmptyDir</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$dirname</code></span>
   )</div>

  <p class="para rdfs-comment">
   Adds an empty directory in the archive.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-ziparchive.addemptydir-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">dirname</code></em></dt>

     <dd>

      <p class="para">
       The directory to add.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-ziparchive.addemptydir-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-ziparchive.addemptydir-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-754">
   <p><strong>Example #1 Create a new directory in an archive</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$zip&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ZipArchive</span><span style="color: #007700">;<br />if&nbsp;(</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">'test.zip'</span><span style="color: #007700">)&nbsp;===&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addEmptyDir</span><span style="color: #007700">(</span><span style="color: #DD0000">'newDirectory'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Created&nbsp;a&nbsp;new&nbsp;root&nbsp;directory'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Could&nbsp;not&nbsp;create&nbsp;the&nbsp;directory'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'failed'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.ziparchive.html">ZipArchive</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ziparchive.addfile.html">ZipArchive::addFile</a></div>
 <div class="up"><a href="class.ziparchive.html">ZipArchive</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
